﻿using Contract.Infrastructure.Repository;
using Contract.Read_WebApi.Application.Commands;
using MediatR;

namespace Contract.Read_WebApi.Application.CommandHandler
{
    public class InfoCYContractCommandHandler : IRequestHandler<InfoCYContractCommand, Domain.Contract>
    {
        private readonly IRepository<Domain.Contract> _repository;

        public InfoCYContractCommandHandler(IRepository<Domain.Contract> repository)
        {
            _repository = repository;
        }

        public async Task<Domain.Contract> Handle(InfoCYContractCommand request, CancellationToken cancellationToken)
        {
            var info = await _repository.GetAsync(x => x.ContractNumber == request.ContractNumber && x.ContractType == 2);
            return info;
        }
    }
}
